<!--
*@author zc
*@date 2023/06/09
*@description 首页
*@fileName index.vue
*@log:
!-->
<template>
    <div>
        <el-button type="success" @click="login">登陆</el-button>
        <el-alert
                style="margin-top: 10px;"
                v-for="(item, key, index) in list"
                type="info"
                :closable="false"
        >
            <template #title>{{ `${item.name} - ${key}` }}</template>
            <el-button type="primary" v-for="child in item.pages" @click="toExample(key,child)">{{
                child.name
                }}
            </el-button>
        </el-alert>
    </div>
</template>

<script>
import {setting} from '@/setting.js'
import http from '@/libs/util.http.js';
import util from "@/libs/util.js";

export default {
    data() {
        return {
            list: setting
        }
    },
    methods: {
        /**
         * 跳转至测试页面
         * @param key 模块标识
         * @param child 页面路由信息
         */
        toExample(key, child) {
            this.$router.push({
                name: `${key}.${child.key}`
            })
        },
        /**
         * 登陆
         */
        async login() {
            const res = await http({
                url: '/api/CISToken/Generator',
                method: 'post',
                data: {
                    account: 'admin',
                    isDomain: false,
                    password: '11ZVee+FsGKmTlXpuYrKTw==',
                    sessionId: util.tools.getUuid(),
                    tenantCode: 'XTSH',
                    validCode: ''
                }
            })
            util.cookies.set('token', res?.result?.accessToken ?? '');
            this.$message.success('token已存储')
        }
    }
}
</script>

<style lang="scss" scoped>
</style>
